package com.example.controller;

import com.example.domain.vo.LoginUserVo;
import com.example.respose.Result;
import com.example.service.impl.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * @author ljs
 * @date 2025/7/22
 */
@RestController
@RequestMapping("/sys")
public class LoginController {

    @Autowired
    private LoginService loginService;

    /**
     * 登录接口
     * @param loginUserVo
     * @return
     */
    @PostMapping("/login")
    public Result login(@RequestBody LoginUserVo loginUserVo, HttpServletResponse httpResponse) {
        String token = loginService.login(loginUserVo);
        httpResponse.addHeader("Authorization", "Bearer,"+"vivid," + token);
        return  Result.success();
    }
}
